package org.example.game;

import javax.swing.*;
import java.awt.*;

public class TankGame extends JFrame {
    private static final int WINDOW_WIDTH = 800;
    private static final int WINDOW_HEIGHT = 600;
    private GamePanel gamePanel;
    private StartPanel startPanel;
    private CardLayout cardLayout;
    private JPanel mainPanel;

    public enum GameMode {
        SINGLE_PLAYER,
        TWO_PLAYERS,
        AI_MODE,
        NETWORK_MODE
    }

    public TankGame() {
        setTitle("坦克大战");
        setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setResizable(false);
        setLocationRelativeTo(null);

        cardLayout = new CardLayout();
        mainPanel = new JPanel(cardLayout);
        
        startPanel = new StartPanel(this);
        gamePanel = new GamePanel(this);
        
        mainPanel.add(startPanel, "START");
        mainPanel.add(gamePanel, "GAME");
        
        add(mainPanel);
        
        // 显示开始界面
        cardLayout.show(mainPanel, "START");
    }

    public void startGame(GameMode mode) {
        cardLayout.show(mainPanel, "GAME");
        gamePanel.startGame(mode);
    }

    public void returnToStart() {
        cardLayout.show(mainPanel, "START");
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            TankGame game = new TankGame();
            game.setVisible(true);
        });
    }
} 